package com.lbn.jfqsc.app.account.recruitment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.lbn.baseframe.base.BaseActivity;
import com.lbn.baseframe.ui.NAppbar;
import com.lbn.baseframe.utils.EasyToast;
import com.lbn.jfqsc.App;
import com.lbn.jfqsc.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RecruitmentActivity extends BaseActivity<RecruitmentPresenter> implements IRecruitmentView {

    @BindView(R.id.user_name)
    TextView userName;
    @BindView(R.id.user_phone)
    TextView userPhone;
    @BindView(R.id.address)
    EditText address;
    @BindView(R.id.skills)
    EditText skills;
    @BindView(R.id.introduce)
    EditText introduce;
    @BindView(R.id.checkbox)
    CheckBox checkbox;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recruitment);
        ButterKnife.bind(this);
        setAppbar(new NAppbar(this));
        appbar.openBack();
        appbar.setTitle("发布招聘");
    }


    public String getIntroduce() {
        return introduce.getText().toString();
    }


    public int getRType() {
        return checkbox.isChecked()?1:2;
    }

    public String getAddress() {
        return address.getText().toString();
    }

    public String getSkills() {
        return skills.getText().toString();
    }


    @Override
    public void onPresenterCreated() {
        super.onPresenterCreated();
        userName.setText(App.getUser().getName());
        userPhone.setText(App.getUser().getPhone());
    }

    @Override
    public RecruitmentPresenter createPresenter() {
        return new RecruitmentPresenter();
    }


    public static void startActivity(Context context) {
        context.startActivity(new Intent(context, RecruitmentActivity.class));
    }

    @Override
    public void onSucceed() {
        EasyToast.showShort(this, "发布成功");
        finish();
    }

    @OnClick(R.id.confirm)
    public void onClick() {
        mPresenter.jobInfo(App.getUser().getName(),getIntroduce(),getSkills(),getAddress(),getRType());
    }
}
